package reflect;

import java.lang.reflect.Method;

public class ReflectDemo6 {
    public static void main(String[] args) throws Exception {
        Class cls = Class.forName("reflect.Person");
        Object obj  = cls.newInstance();

        //Method method = cls.getMethod("hehe");
         Method method = cls.getDeclaredMethod("hehe");
         method.setAccessible(true);//强行打开访问权限
         method.invoke(obj);
         method.setAccessible(false);//用后应当及时关闭访问权限
    }
}
